<template>
	<el-form ref="form" :model="form" label-width="80px">
		<el-form-item label="sid">
			<el-input :disabled="true" v-model="form.sid"></el-input>
		</el-form-item>
		<el-form-item label="sname">
			<el-input v-model="form.sname" value="form.CouName"></el-input>
		</el-form-item>
		<el-form-item label="sex">
			<el-input v-model="form.sex"></el-input>
		</el-form-item>
		<el-form-item label="birth">
			<el-input v-model="form.birth"></el-input>
		</el-form-item>

		<el-form-item label="major">
			<el-input v-model="form.major"></el-input>
		</el-form-item>
		<el-form-item label="credits">
			<el-input v-model="form.credits"></el-input>
		</el-form-item>
		<el-form-item>
			<el-button type="primary" @click="upone11">立即创建</el-button>
			<el-button>取消</el-button>
		</el-form-item>
	</el-form>
	{{form}}
</template>

<script>
	// import qs from "qs";
	import router from "../../router";
	// import VueCookies from "vue-cookies";

	const axios = require('axios');
	export default {
		name: "updata",
		data() {
			return {
				form: {
					sid: '',
					sname: '',
					sex: '',
					birth: '',
					major: '',
					credits: ''
				},
				teacherlist: [],
				DepartNos: []
			}
		},
		created() {
			this.form = this.$route.params;
			this.teachers();
			console.log(this.$route.params)
		},
		methods: {
			teachers() {
				// axios({
				// 		method: 'get',
				// 		url: 'http://localhost/teacherlist.php',
				// 	})
				// 	.then((res) => {
				// 		console.log(res.data);
				// 		this.teacherlist = res.data.tlist;
				// 		this.DepartNos = res.data.dlist;
				// 	})
				// 	.catch((err) => {
				// 		console.log(err)

				// 	}),

			},
			upone11() {
				// axios.post({

				// 	dataType: "json",
				// 	url: "http://localhost:8000/update",
				// 	// contentType: "application/json;charset=UTF-8", //指定消息请求类型
				// 	data: JSON.stringify(this.form), //将js对象转成json对象
				// 	success: function(data) {
				// 		console.log(data)
				// 	}
				// });
				axios.post('http://localhost:8000/update', this.form)
					.then(function(response) {
						console.log(response);
						router.push({
							name: 'list'
						});
					})
					.catch(function(error) {
						console.log(error);
					});
			}
		}

	}
</script>

<style scoped>

</style>
